package 回溯;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

//https://leetcode.cn/problems/letter-tile-possibilities/
public class 活字印刷 {
    int count = 0;
    char[] cha;
    public int numTilePossibilities(String tiles) {

        cha = tiles.toCharArray();
        boolean[] have = new boolean[cha.length];
        Arrays.sort(cha);
        fun(have);
        return count;
    }

    private void fun(boolean[] have) {
        char last = '+';
        for (int i = 0; i < cha.length; i++) {
            if (!have[i] && cha[i] != last){
                count ++;
                have[i] = true;
                fun( have);
                have[i] = false;
                last = cha[i];
            }
        }
    }
}
